﻿using Application.PermissionService;
using Domain.Entity.zct;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WMSManage.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]//需要鉴权
    public class PermissionController : ControllerBase
    {
        private readonly IPermissionService permissionService;

        public PermissionController(IPermissionService permissionService)
        {
            this.permissionService = permissionService;
        }


        /// <summary>
        /// 根据用户角色id显示菜单权限
        /// </summary>
        /// <param name="rid">角色id</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<EPermission>> GetMeau(int rid)
        {
            return await permissionService.GetMeau(rid);
        }

        /// <summary>
        /// 获取所有权限并构建树形结构
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<EPermission>> GetAllPermissionTree()
        {
            return await permissionService.GetAllPermissionTree();
        }


        /// <summary>
        /// 获取所有权限数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Permission>> GetAllPermissions()
        {
            return await permissionService.GetAllPermissions();
        }
    }
}
